const { no, ok, getClientIp } = require('../../utils/utlis');
const visitorService = require('../../services/client/visitorService');
const JWT = require('../../utils/jwt');
module.exports = {
	add: async (req, res, next) => {
		try {
			let token = JWT.decrypt(req.headers.token);
			let { id: userId } = token;

			let ipv6 = getClientIp(req);
			await visitorService.add(ipv6, userId);
			res.send(ok('访客添加成功'));
		} catch (error) {
			res.send(no(error.message));
		}
	}
};
